const express = require('express')
const database = require('../../database')

const router = express.Router()

router.get('/getUserInfo', (request, response) => {
    const info = request.auth//获得解析结果
    const sql = 'select * from user where username = ?'
    database.query(sql, [info.username], (error, result) => {
        if(error) {
            response.status(417).end()
        } else {
            let userInfo = result[0]
            userInfo.password = undefined
            response.send(userInfo)
        }
    })
})

module.exports = router